package com.wolfpire.workflow.cmd;

import org.hibernate.Session;
import org.jbpm.api.Execution;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
import org.jbpm.pvm.internal.model.ExecutionImpl;

/**
 * 暂停活动任务  Cmd类
 * @author linRJ
 *
 */
public class SuspendedExecTaskCmd implements Command<Object> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2368250299750522873L;
	
	Long execId ;
	

	public SuspendedExecTaskCmd(Long execId) {
		this.execId = execId;
	}


	public Object execute(Environment environment) throws Exception {
		Session session = environment.get(Session.class);
		ExecutionImpl execution = (ExecutionImpl)session.get(ExecutionImpl.class,execId);
		if( !execution.isSuspended()){
			execution.setState(Execution.STATE_SUSPENDED);
		}
		return null;
	}

}
